#include <stdio.h>

#include "double-stack.h"

int PrintStack(DubStack stack,stack_name name);

ElemType s;

DubStack MyStack;

int main(void){
    InitStack(&MyStack);
    Push(&MyStack,1,a);
    Push(&MyStack,2,a);
    Push(&MyStack,3,a);
    Push(&MyStack,4,a);
    Push(&MyStack,5,a);

    Pop(&MyStack,&s,a);
    Pop(&MyStack,&s,b);

    Pop(&MyStack,&s,a);

    Push(&MyStack,10,b);
    Push(&MyStack,20,b);
    Push(&MyStack,30,b);
    Pop(&MyStack,&s,b);
    Push(&MyStack,40,b);
    Push(&MyStack,50,b);

    PrintStack(MyStack,a);
    PrintStack(MyStack,b);

    DestroyStack(&MyStack);
}

int PrintStack(DubStack stack,stack_name name){
    if (stack.data == NULL || stack.capacity == 0){
        return(-1);
    }
    switch (name) {
        case a:{
            while (stack.top1 != 0){
                printf("%d ",stack.data[stack.top1--]);
            }
            putchar('\n');
            return(0);
        }
        case b:{
            while (stack.top2 != stack.capacity-1){
                printf("%d ",stack.data[stack.top2++]);
            }
            putchar('\n');
            return(0);
        }
        default:{
            return(-1);
        }
    }
}